{%- extends '_header.jinja' -%}
{%- import '_macro.jinja' as func -%}

{% block file_header %}{% if file_note -%}
	{{- func.file_header(file_name,copyright,author,date,summary,note) -}}
{% endif %}{% endblock %}


{%- block include -%}
	{%- if includes -%}
		{%- for one_include in includes %}{% if not one_include is contain('.') %}
#include "{{ one_include }}.h"
		{% endif %}{%- endfor -%}
	{%- endif -%}

{# class dependency #}
	{%- if supers -%}
		{%- for parent_name,parent_vtables in supers.iteritems() %}
#include "{{ parent_name }}.h"
		{%- endfor -%}
	{%- endif -%}
{%- endblock -%}


{%- block forward_declare -%}
{%- if _have_vtable_new -%}
struct {{ name }}_ops;
{%- endif -%}
{%- endblock -%}


{%- block class_definition -%}
{% if comment %}/** {{ comment }} */{% endif %}
struct {{ name }} {
	{%- if supers -%}
		{%- for parent_name,parent_vtables in supers.iteritems() %}
	struct {{ parent_name }} {{ parent_name }};
		{%- endfor -%}
	{%- endif -%}

	{%- if _have_vtable_new %}
	struct {{ name }}_ops *ops;
	{%- endif -%}

	{{- func.macro_loop_functions(trace,name,vars,'vars',mode='var',static='False') }}
};
{%- endblock -%}


{%- block vtable_declare -%}
{%- if _have_vtable_new -%}
struct {{ name }}_ops {
	{%- block parents %}{% endblock -%}
	{{- func.macro_loop_functions(trace,name,virtuals,'virtuals',mode='declare') -}}

	{%- if _have_super_ref %}
	struct {{ name }}_ops *__super;
	{%- endif -%}
	{{- func.macro_loop_functions(trace,name,vars,'vars',mode='var',static='True') }}
};
{%- endif -%}
{%- endblock -%}


{%- block class_init -%}
	{{- func.macro_loop_functions(trace,name,inits,'inits',scope='public',mode='declare-init') -}}
{%- endblock -%}

{%- block private_class_init -%}
	{{- func.macro_loop_functions(trace,name,inits,'inits',scope='private',mode='declare-init-private') -}}
{%- endblock -%}

{%- block public_methods -%}
	{{- func.macro_loop_functions(trace,name,methods,'methods',scope='public',mode='declare') -}}
{%- endblock -%}


{%- block vtable_helper -%}
{%- if _have_vtable_new -%}
	{{- func.macro_loop_functions(trace,name,virtuals,'virtuals',mode='impl-ops',qualifier='static inline',format_str='%s_%s') -}}
{%- endif -%}
{%- endblock -%}

{%- block inline_method -%}
	{{- func.macro_loop_functions(trace,name,inlines,'inlines',mode='impl-print',scope='public', qualifier='static inline') }}
{%- endblock -%}

